package com.atguigu.srb.core.controller.api;

import com.atguigu.srb.common.result.R;
import com.atguigu.srb.core.pojo.entity.Dict;
import com.atguigu.srb.core.service.DictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 数据字典 前端控制器
 * </p>
 *
 * @author javaCode
 * @since 2025-07-19
 */
@Api(tags = "数据字典")
@RestController
@RequestMapping("/api/core/dict")
@RequiredArgsConstructor
public class DictController {

    // 数据字典 服务类
    private final DictService dictService;

    /**
     * 根据dictCode获取下级节点
     */
    @ApiOperation("根据dictCode获取下级节点")
    @GetMapping("/findByDictCode/{dictCode}")
    public R findByDictCode(@ApiParam(value = "节点编码", required = true) @PathVariable String dictCode) {

        List<Dict> list = dictService.findByDictCode(dictCode);

        return R.ok().data("dictList", list);
    }

}
